package demo.myactuator;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

import util.StatusUtil;


@Component("myHealthIndicator")
public class MyHealthIndicator implements HealthIndicator{
	
		@Override
	    public Health health() {
			Object myHealthStatus = StatusUtil.get("myHealthStatus");
			String myHealthStatusStr = null;
			if(myHealthStatus!=null) {
				myHealthStatusStr = myHealthStatus.toString();
			}else {
				myHealthStatusStr = "ok";
			}
			
			
	        if("ok".equalsIgnoreCase(myHealthStatusStr )){
	        	return Health.up().withDetail("myHealthStatus",myHealthStatusStr).build();
	        }
	        return Health.down().withDetail("myHealthStatus",myHealthStatusStr).build();
	    }
	
		
}
	